//***************************************************************************
//*
//*	File:			FolderDialog.h
//*	Description:	Folder dialog
//*
//***************************************************************************
//*
//*	Note:			This source code is provided "as is" meaning that you may 
//*					use it at your own risk. 
//*					You are free to use it in any way you like.
//*
//***************************************************************************
//*
//*	History:		
//*
//*	-------------------------------------------------------------------------
//*	2003/07/27	|	Initial release									|	rk
//*	-------------------------------------------------------------------------
//*
//***************************************************************************

//
//-------------------------------------------------------------- PREPROCESSOR 
//

#ifndef			__FOLDERDIALOG_H_INCLUDED
#define			__FOLDERDIALOG_H_INCLUDED

#if				_MSC_VER > 1000
#pragma once
#ifdef			__SWITCH_SHOW_HEADER
#pragma message ("-- FolderDialog.h\n")
#endif
#ifdef			__SWITCH_SHOW_HEADER_TREE
#pragma message ("-- "__FILE__"\n")
#endif
#endif 

//
//-------------------------------------------------------------- DEPENDENCIES
//

//
//--------------------------------------------------------------- DEFINITIONS
//

#ifndef BIF_USENEWUI
	#pragma message ( "-- FolderDialog.h \tDefining missing BrowseInFo constants" )
	#define BIF_RETURNONLYFSDIRS   0x0001											// For finding a folder to start document searching
	#define BIF_DONTGOBELOWDOMAIN  0x0002											// For starting the Find Computer
	#define BIF_STATUSTEXT         0x0004											// Top of the dialog has 2 lines of text for BROWSEINFO.lpszTitle and one line if
																					// this flag is set.  Passing the message BFFM_SETSTATUSTEXTA to the hwnd can set the
																					// rest of the text.  This is not used with BIF_USENEWUI and BROWSEINFO.lpszTitle gets
																					// all three lines of text.
	#define BIF_RETURNFSANCESTORS  0x0008											
	#define BIF_EDITBOX            0x0010											// Add an editbox to the dialog
	#define BIF_VALIDATE           0x0020											// insist on valid result (or CANCEL)
																					
	#define BIF_NEWDIALOGSTYLE     0x0040											// Use the new dialog layout with the ability to resize
																					// Caller needs to call OleInitialize() before using this API

	#define BIF_USENEWUI           (BIF_NEWDIALOGSTYLE | BIF_EDITBOX)

	#define BIF_BROWSEINCLUDEURLS  0x0080											// Allow URLs to be displayed or entered. (Requires BIF_USENEWUI)
	#define BIF_UAHINT             0x0100											// Add a UA hint to the dialog, in place of the edit box. May not be combined with BIF_EDITBOX
	#define BIF_NONEWFOLDERBUTTON  0x0200											// Do not add the "New Folder" button to the dialog.  Only applicable with BIF_NEWDIALOGSTYLE.
	#define BIF_NOTRANSLATETARGETS 0x0400											// don't traverse target as shortcut
																					
	#define BIF_BROWSEFORCOMPUTER  0x1000											// Browsing for Computers.
	#define BIF_BROWSEFORPRINTER   0x2000											// Browsing for Printers
	#define BIF_BROWSEINCLUDEFILES 0x4000											// Browsing for Everything
	#define BIF_SHAREABLE          0x8000											// sharable resources displayed (remote shares, requires BIF_USENEWUI)
#endif

//
//--------------------------------------------------------- CLASS DECLARATION
//

//***************************************************************************
//**	@DOC		CLASS CFolderDialog
//***************************************************************************
//*		@CLASS		Dialog for selecting a folder
//**	@COMM		Wrapper for SHBrowseForFolder
//***************************************************************************
class CFolderDialog  
{
	//																											
	//-----------------------------------------------------------------------									
	//***************************     ATTRIBS     ***************************									
	//-----------------------------------------------------------------------									
	//																											
private:																												// @ACCESS	Private Attributes	
			BROWSEINFO		m_BrowseInfo						;														// @CMEMBER	Browse info structure
			CString			m_strPath							;														// @CMEMBER	The current path
			LPITEMIDLIST	m_pidPath							;														// @CMEMBER	The current path's id
			LPITEMIDLIST	m_pidRootPath						;														// @CMEMBER	The root path's id
			LPITEMIDLIST	m_pidInitialPath					;														// @CMEMBER	The initial path's id
			HWND			m_hWnd								;														// @CMEMBER	Window handle of the actual dialog
																										
	//																													
	//-----------------------------------------------------------------------											
	//***************************     GET/SET     ***************************											
	//-----------------------------------------------------------------------											
	//																													
public:																													// @ACCESS	Public Get/Set Methods
			CString			GetPath								( void )									const	;	// @CMEMBER	Retruns the path the user selected
			CString			GetRootPath							( void )									const	;	// @CMEMBER	Retruns the root path
			CString			GetInitialPath						( void )									const	;	// @CMEMBER	Retruns the initial path
																										
			BOOL			IsNewStyle							( void )									const	;	// @CMEMBER	Determines whether the dialog is set up to use new style
			BOOL			IsBrowseForComputer					( void )									const	;	// @CMEMBER	Determines whether the dialog is set up to browse for computers
			BOOL			IsBrowseForPrinter					( void )									const	;	// @CMEMBER	Determines whether the dialog is set up to browse for printers
																										
			BOOL			HasHint								( void )									const	;	// @CMEMBER	Determines whether the dialog has a UA hint
			BOOL			HasEditBox							( void )									const	;	// @CMEMBER	Determines whether the dialog has an edit box
			BOOL			HasStatusText						( void )									const	;	// @CMEMBER	Determines whether the dialog has a status text
			BOOL			HasNewFolderButton					( void )									const	;	// @CMEMBER	Determines whether the dialog has a "New Folder" button
																										
			BOOL			DoesValidate						( void )									const	;	// @CMEMBER	Determines whether the dialog is set up validate the path (i.e. not return invalid paths)
			BOOL			DoesIncludeURLs						( void )									const	;	// @CMEMBER	Determines whether the dialog is set up include URLs
			BOOL			DoesIncludeFiles					( void )									const	;	// @CMEMBER	Determines whether the dialog is set up include files
			BOOL			DoesIncludeShares					( void )									const	;	// @CMEMBER	Determines whether the dialog is set up include shares
			BOOL			DoesTranslateTargets				( void )									const	;	// @CMEMBER	Determines whether the dialog is set up to translate targets
			BOOL			DoesGoBelowDomain					( void )									const	;	// @CMEMBER	Determines whether the dialog is set up to browse below domain level
			BOOL			DoesReturnFileSystemAncestors		( void )									const	;	// @CMEMBER	Determines whether the dialog is set up to return file system ancestors
			BOOL			DoesReturnOnlyFileSystemDirs		( void )									const	;	// @CMEMBER	Determines whether the dialog is set up to return only file system directories
																										
			BOOL			HasFlags							(		DWORD			a_dwFlags		)	const	;	// @CMEMBER	Determines whether the dialog has the specified flags
																										
			void			EnableNewStyle						(		BOOL			a_bEnable		)			;	// @CMEMBER	Sets the dialog up to use new style
			void			EnableBrowseForComputer				(		BOOL			a_bEnable		)			;	// @CMEMBER	Sets the dialog up to browse for computers
			void			EnableBrowseForPrinter				(		BOOL			a_bEnable		)			;	// @CMEMBER	Sets the dialog up to browse for printers
																										
			void			EnableHint							(		BOOL			a_bEnable		)			;	// @CMEMBER	Sets the dialog up to have a UA hint
			void			EnableEditBox						(		BOOL			a_bEnable		)			;	// @CMEMBER	Sets the dialog up to have an edit box
			void			EnableStatusText					(		BOOL			a_bEnable		)			;	// @CMEMBER	Sets the dialog up to have a status text
			void			EnableNewFolderButton				(		BOOL			a_bEnable		)			;	// @CMEMBER	Sets the dialog up to hava a "New Folder" button
																										
			void			EnableValidate						(		BOOL			a_bEnable		)			;	// @CMEMBER	Sets the dialog up to validate the path (i.e. not return invalid paths)
			void			EnableIncludeURLs					(		BOOL			a_bEnable		)			;	// @CMEMBER	Sets the dialog up to include URLs
			void			EnableIncludeFiles					(		BOOL			a_bEnable		)			;	// @CMEMBER	Sets the dialog up to include files
			void			EnableIncludeShares					(		BOOL			a_bEnable		)			;	// @CMEMBER	Sets the dialog up to include shares
			void			EnableTranslateTargets				(		BOOL			a_bEnable		)			;	// @CMEMBER	Sets the dialog up to translate targets
			void			EnableGoBelowDomain					(		BOOL			a_bEnable		)			;	// @CMEMBER	Sets the dialog up to not browse below domain level
			void			EnableReturnFileSystemAncestors		(		BOOL			a_bEnable		)			;	// @CMEMBER	Sets the dialog up to return file system ancestors
			void			EnableReturnOnlyFileSystemDirs		(		BOOL			a_bEnable		)			;	// @CMEMBER	Sets the dialog up to return only file system directories
																										
			void			SetRootPath							(		LPITEMIDLIST	a_pidPath		)			;	// @CMEMBER	Sets the root	 path
			void			SetRootPath							( const CString&		a_strPath		)			;	// @CMEMBER	Sets the root	 path
			void			SetInitialPath						(		LPITEMIDLIST	a_pidPath		)			;	// @CMEMBER	Sets the initial path
			void			SetInitialPath						( const CString&		a_strPath		)			;	// @CMEMBER	Sets the initial path
																										
			void			ModifyFlags							(		DWORD			a_dwRemove		
																,		DWORD			a_dwAdd			)			;	// @CMEMBER	Modifies the dialog;s flags
																										
	//																													
	//-----------------------------------------------------------------------											
	//*************************     INFORMATION     *************************							
	//-----------------------------------------------------------------------											
	//																													
public:																													// @ACCESS	Public Information Methods
			LPITEMIDLIST	GetPIDLFromPath						(		LPCSTR			a_pszPath		)			;	// @CMEMBER	Determines the item id list for the specified path
																										
	//																												
	//-----------------------------------------------------------------------										
	//************************     MODIFICATION     *************************							
	//-----------------------------------------------------------------------										
	//																												
public:																													// @ACCESS	Public Modification Methods
			void			EnableOK							(		BOOL			a_bEnable		)			;	// @CMEMBER	Enables or disables the OK button
			void			SetSelection						(		LPCITEMIDLIST	a_pidPath		)			;	// @CMEMBER	Selects the specified folder
			void			SetSelection						(		LPCSTR			a_pszPath		)			;	// @CMEMBER	Selects the specified folder
			void			SetStatusText						(		LPCSTR			a_pszText		)			;	// @CMEMBER	Sets the specified status text
																										
	//																													
	//-----------------------------------------------------------------------											
	//**************************     EXECUTION     **************************											
	//-----------------------------------------------------------------------											
	//																													
public:																													// @ACCESS	Public Execution Methods
			UINT			DoModal								( void )											;	// @CMEMBER	Runs the modal dialog
																												
	//																													
	//-----------------------------------------------------------------------											
	//**************************     CALLBACKS     **************************							
	//-----------------------------------------------------------------------											
	//																													
private:																												// @ACCESS	Private Callback Handlers
	static	int	CALLBACK	S_ReceiveMessage					(		HWND			a_hWnd			
																,		UINT			a_uiMsg			
																,		LPARAM			a_lParam		
																,		LPARAM			a_pData			)			;	// @CMEMBER	Callback function to recevie interceptable messages
																										
	//																													
	//-----------------------------------------------------------------------											
	//**************************     VIRTUALS     ***************************							
	//-----------------------------------------------------------------------											
	//																													
protected:																												// @ACCESS	Protected Overridables
			void			OnInitialized						( void )											;	// @CMEMBER	Called when the dialog has been initialized
			void			OnSelChanged						(		LPCITEMIDLIST	a_pidSelected	)			;	// @CMEMBER	Called when the selection changed
			void			OnValidateFailed					(		LPCSTR			a_pszName		)			;	// @CMEMBER	Called when the validation of the current path failed
																													
	//																										
	//-----------------------------------------------------------------------								
	//***********************     CON/DESTRUCTION     ***********************								
	//-----------------------------------------------------------------------								
	//																										
public:																													// @ACCESS	Public Con-/Destruction Methods	
			 CFolderDialog	(		LPCSTR		a_pszTitle			= NULL												
							,		LPCSTR		a_pszDescription	= NULL												
							,		LPCSTR		a_strInitialPath	= NULL												
							,		LPCSTR		a_strRootPath		= NULL												
							,		DWORD		a_dwStyle			= BIF_EDITBOX										
																	| BIF_STATUSTEXT									
																	| BIF_RETURNONLYFSDIRS
																	| BIF_USENEWUI										
							,		CWnd*		a_pwndOwner			= NULL				);								// @CMEMBER	Default constructor
	virtual ~CFolderDialog();															
};
//***************************************************************************
//**	@END
//***************************************************************************

#endif // __FOLDERDIALOG_H_INCLUDED
